<!DOCTYPE html>
<html lang="en" ng-app="app" ng-controller="myApp" data-title="经销商推荐的门店经理">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>{{title}}</title>
    <link rel="stylesheet" href="./static/css/base.css">
    <link rel="stylesheet" href="./static/css/kps.css">
</head>

<body ng-cloak class="ng-cloak">
<div class="title">
        <span>
            < </span>
    服务评价
</div>
<div class="main" ng-show="is">
    <div class="kps">
        <div class="info">
            <div class="infoImg"><img ng-src="{{person.saleman.avatar}}" alt=""></div>
            <div class="infoName"><span>{{person.saleman.name}}</span><br> <span>{{person.saleman.position?person.saleman.position:'客户经理'}}</span>
            </div>
        </div>
    </div>
    <div class="kpsstar">
        <p>评价内容</p>
        <div class="stars">
            <div class="staritem">
                <span class="starspan">服务态度</span>
                <span class="starscore" ng-repeat="(index,item) in star"
                      ng-class="{starscoreCur:index<attitudeIndex}" ng-click="attitudeCk(index)">&#9733;</span>
            </div>
            <div class="staritem">
                <span class="starspan">专业知识</span>
                <span class="starscore" ng-repeat="(index,item) in star"
                      ng-class="{starscoreCur:index<professionIndex}" ng-click="professionCk(index)">&#9733;</span>
            </div>
            <div class="staritem">
                <span class="starspan">反馈及时度</span>
                <span class="starscore" ng-repeat="(index,item) in star"
                      ng-class="{starscoreCur:index<responseIndex}" ng-click="responseCk(index)">&#9733;</span>
            </div>
        </div>
        <span>你的评价让我们做的更好</span>
    </div>
    <div class="commit">
        <div class="submit" ng-click="sub()">提交</div>
    </div>
</div>
<div class="result" ng-hide="is">
    评价成功感谢你对我们工作的支持
</div>


<!-- js -->
<script src="./static/js/lib/pxRem.js"></script>
<script src="./static/js/lib/jquery.min.js"></script>
<script src="./static/js/lib/angular.js"></script>
<script src="./static/js/lib/vconsole.min.js"></script>
<script src="./static//js/server.js"></script>

<script>
    var app = angular.module("app", ['myserver']);
    app.controller('myApp', ['$scope', '$http', '$rootScope', '$q', '$window', 'axios','wxAlert', function ($scope, $http, $rootScope,
                                                                                                  $q, $window, axios,wxAlert) {
        $scope.id = $window.location.href.split('wxDepartmentId=')[1] ? '10000187' : '10000187'

        $scope.is = 1
        //星星数量
        $scope.star = [0, 1, 2, 3, 4];
        $scope.attitudeIndex = null;//态度评星数
        $scope.professionIndex = null;//职业评星数
        $scope.responseIndex = null;//反馈评星数
        $scope.person = {
            "openId": "omq8ft796GVqSIgYhW_6o0-WKImU",
            "saleman": {
                "id": 95,
                "userId": "2017011000053587",
                "name": "朱元春",
                "position": "金融保险经理",
                "mobile": "15806123636",
                "department": 10001261,
                "gender": 1,
                "qrCode": null,
                "email": "147938632@qq.com",
                "avatar": "http://p.qlogo.cn/bizmail/ibTSRpEE3eWpicQJXVc42y9B5EB9aIo9FUMbNJcGG6SeYlBibSaFInSKw/0",
                "englishName": null,
                "countCustomer": null,
                "score": null,
                "shopId": null
            }
        }

        /*态度评星*/
        $scope.attitudeCk = function (index) {

            $scope.attitudeIndex = index + 1
            console.log($scope.attitudeIndex);
        }
        /*职业评星*/
        $scope.professionCk = function (index) {

            $scope.professionIndex = index + 1
            console.log($scope.professionIndex);
        }
        /*反馈评星*/
        $scope.responseCk = function (index) {

            $scope.responseIndex = index + 1
            console.log($scope.responseIndex);
        }

        var data = {
            openId: $scope.person.openId,
            salemanId: $scope.person.saleman.id,
            attitude: $scope.attitudeIndex,
            profession: $scope.professionIndex,
            response: $scope.responseIndex
        }

        $scope.sub = function () {
            if(!$scope.attitudeIndex||!$scope.professionIndex||!$scope.responseIndex){
                wxAlert.tooltip('请先评分再提交')
                return
            }

            data.attitude = $scope.attitudeIndex,
            data.profession = $scope.professionIndex,
            data.response = $scope.responseIndex
            axios.scoreItem(data).then(function (res) {
                if(res.code){
                    wxAlert.tooltip('评价未成功:'+res.msg)
                    return
                }else {
                    $scope.is = 0;
                }

            })
        }

    }])
</script>
</body>

</html>